home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1992-05-08 | 15.9 KB | 404 lines | [ TEXT/MPS ]
########################################################################## ################### Printing.lib ########################## #========================================================================= # Author: O. Güracar # Description:This library supports the most common settings for # Page Setup and Printing. You can easily modify the routine # PrintDocument to support any additions to the PageSetup and Print # dialogs that an application may use. # At present there is support for the ImageWriter and LaserWriter # In the future there will be support for the StyleWriter, Personal # LaserWriter LS etc. Watch for new revs. # # DoOrientation (Select Portrait or landscape) # DoPopUp (Select non-standard popup item) # DoRanScale (Scale randomly with range) # SelectScale (Scale with any list of scale values) # DoCheckBox (Select random checkboxes) # PrintPage (Prints How ever many pages specified) # InitLaserGlobals (Initializes the globals for the LaserWriter) # InitImageGlobals (Initializes the globals for the LaserWriter) # PrintDocument (The control-Selects all options on PageSetup and Print Dialog) # # Copyright Apple Computer, Inc. 1985-1992 # All rights reserved #========================================================================= # OYG 3/13/92 Created version 1.0 ########################################################################## Libraries 'Controls.lib','ShimSquad.lib'; ########################################################################## # DoOrientation(OrientLoc,Orientation) #========================================================================= # Author: O. Güracar # Description: This task selects which way the paper will be printed # (Landscape or portrait). You just need to pass the # location of the Portrait control and which control to # choose. NOTE:The task needs the Portrait control # location to find both controls. # Parameters: OrientLoc - the relative location of Portrait control # Orientation - Which control to choose # "L" for Lanscape "P" for Portrait #========================================================================= # Example: DoOrientation({122,169},"L"); #========================================================================= # History: # OYG 3/30/92 Created ########################################################################## Task DoOrientation(OrientLoc,Orientation) begin Global PrinterName; if (PrinterName = "") Global PrinterName:="unnamed Printer"; if (Orientation = "L") begin MoveRelativeToWindow((OrientLoc[1]+40),OrientLoc[2]);#Select Landscape click; LogStr("{PrinterName}-••Selected LandScape orientation for {PrinterName}••"); end; if (Orientation = "P") begin MoveRelativeToWindow(OrientLoc[1],OrientLoc[2]);#Select Portrait click; LogStr("{PrinterName}-••Selected Portrait orientation for {PrinterName}••"); end; if (Orientation <>"L" and Orientation <>"P") begin LogStr('No Orientation selected'); end; end; ########################################################################## # DoCheckBox(CheckBoxList) #========================================================================= # Author: O. Güracar # Description: This task unselects all checkboxes and then randomly # selects the checkboxes passed in the list CheckBoxList # Parameters: CheckBoxList - a list of checkbox names to be selected # randomly. # ex:MyCheckBoxList:={'Font Substitution?','Text Smoothing?'}; #========================================================================= # Example: DoCheckBox(MyCheckBoxList); #========================================================================= # History: # OYG 3/30/92 Created ########################################################################## Task DoCheckBox(CheckBoxList) begin Global PrinterName; CheckBoxMax:=(card CheckBoxList); #How many check boxes in the list CheckHowMany:=random(1,CheckBoxMax); #gets a random number of check boxes to check for j:=1 to CheckBoxMax do #loop to UnSelect all check boxes begin CheckBoxItem:=CheckBoxList[j]; if (match[checkbox t: "{CheckBoxItem}" w:[window o:1] s:{1,1}]!) begin Select [checkbox t: "{CheckBoxItem}"]; #UnSelect CheckBox end; end; for i:=1 to CheckHowMany do #loop to Select random check boxes begin CheckBoxItemNum:=random(1,CheckBoxMax); CheckBoxName:=CheckBoxList[CheckBoxItemNum]; if (match[checkbox t: "{CheckBoxName}" w:[window o:1] s:{0,1}]!) begin Select [checkbox t: "{CheckBoxName}"]; #Selects CheckBox LogStr("{PrinterName}-••Selected {CheckBoxName}••"); end; else begin end; end; end; ########################################################################## # DoRadioButton(RadioButt) #========================================================================= # Author: O. Güracar # Description: This task selects random radio buttons that are passed # in as a list. The routine selects one radio buttons # randomly. # Parameters: RadioButt - List of radio buttons to choose from. #========================================================================= # Example: DoRadioButton(RadioButt); #========================================================================= # History: # OYG 5/6/92 Created ########################################################################## task DoRadioButton(RadioButt) begin Global PrinterName; MaxRadioNum:=(Card RadioButt); WhichRadio:=random(1,MaxRadioNum); radioItem:=RadioButt[WhichRadio]; SelectRadioButton("{radioItem}"); LogStr("{PrinterName}-••Selected radio button {radioItem}••"); end; ########################################################################## # DoPopUp(PopUpControlName,PopUpList,PopUpArray) #========================================================================= # Author: O. Güracar # Description: This task Resets the popup to the first item in the list # and then selects the chosen item from a non-standard Popup. # Parameters: PopUpControlName - Name of Control popup. # PopUpList - List of names and the position in the list # of Items from popup. # PopUpArray - List of PopUpList # ex: Color:={{'Black & White',0},{'Gray',1}}; # # #========================================================================= # Example: DoPopUp("Paper:",Paper[pItem],Paper); #========================================================================= # History: # OYG 3/30/92 Created ########################################################################## Task DoPopUp(PopUpControlName,PopUpList,PopUpArray) begin Global PrinterName; if ((Card PopUpArray)=1) PopUpListMax:=1; else PopUpListMax:=(Card PopUpArray)-1; PopUpItemName:=PopUpList[1]; PopUpNumber:=PopUpList[2]; if (match [control t:"{PopUpControlName}" e:true]!) begin while not match [control t:"{PopUpControlName}" s:{0,PopUpListMax}]! begin z:= match[control t: "{PopUpControlName}" s:{0,PopUpListMax}]; LogStr(" {PopUpControlName},{PopUpItemName},{PopUpNumber},{PopUpListMax}"); select [control t: "{PopUpControlName}"]; DoPressMouse(); wait(1); #Delay for PopUp to appear MoveMouse(0,-16,0,0); #Scroll Up PopUp list by one item wait(1); #Delay for PopUp to appear DoReleaseMouse(); #Release the Mouse to select end; select [control t: "{PopUpControlName}"]; ItemSelection:=16*PopUpNumber; #16 * Displacement to next popup item DoPressMouse(); wait(1); #Delay for PopUp to appear MoveMouse(0,ItemSelection,0,0); #Scroll Up PopUp list by PopUpList wait(1); #Delay for PopUp to appear DoReleaseMouse("{PrinterName}-••Selected PopUp {PopUpItemName}••"); #Release the Mouse to select end; else LogStr("{PrinterName}-••PopUp menu {PopUpControlName} is disabled••"); end; ########################################################################## # DoRanScale(ScaleFieldLoc,lower,upper) #========================================================================= # Author: O. Güracar # Description: This task generates a random number for the scale text # field. # Parameters: ScaleFieldLoc - value for the relative location of middle of # Text Edit field. {Must be in array with curly brackets} # lower - the lower bound for the random number # the default is 5 # upper - the upper bound for the random number # the default is 999 #========================================================================= # Example: DoRanScale({122,169},9,100); #========================================================================= # History: # OYG 3/30/92 Created ########################################################################## Task DoRanScale(ScaleFieldLoc,lower:=5,upper:=999) begin Global PrinterName; ran:=Random(lower,upper); MoveRelativeToWindow(ScaleFieldLoc[1],ScaleFieldLoc[2]); #Move to Scale text field] doubleClick; TypeStr("{ran}"); #Places random number in scale field LogStr("{PrinterName}-••Selected scale:{ran}••"); MoveRelativeToWindow(ScaleFieldLoc[1],ScaleFieldLoc[2]); #Move to Scale PopUp doubleClick; end; ########################################################################## # SelectScale(ScaleFieldLoc,Scale) #========================================================================= # Author: O. Güracar # Description: This task sets the scale in the scale text edit field # the scale is stored in a list and the individual items # are passed in "scale" # Parameters: ScaleFieldLoc - value for the relative location of middle of # Text Edit field. {Must be in array with curly brackets} # Scale - the scale to be selected #========================================================================= # Example: SelectScale({122,169},73); #========================================================================= # History: # OYG 3/30/92 Created ########################################################################## Task SelectScale(ScaleFieldLoc,Scale:=100) begin Global PrinterName; MoveRelativeToWindow(ScaleFieldLoc[1],ScaleFieldLoc[2]); #Move to Scale text field] doubleClick; TypeStr("{Scale}"); #Places predetermined number in scale field LogStr("{PrinterName}-••Selected scale:{Scale}% ••"); MoveRelativeToWindow(ScaleFieldLoc[1],ScaleFieldLoc[2]); #Move to Scale PopUp doubleClick; end; ########################################################################## # PrintPage(NumOfPages) #========================================================================= # Author: O. Güracar # Description: This task prints pages and then reselects Page Setup # dialog. # Parameters: NumOfPages - how many pages to print default to ALL #========================================================================= # Example: PrintPage(2); #========================================================================= # History: # OYG 3/30/92 Created ########################################################################## Task PrintPage(NumOfPages:="1") begin Global PrinterName,DocName; If (NumOfPages = "all")begin SelectButton("Print"); LogStr("{PrinterName}-••Printing {NumOfPages} pages••"); end; Else begin select[radioButton t:"From:"]; if (PrinterName = "ImageWriter") Type k:{tabKey}; TypeStr("1"); Type k:{tabKey}; TypeStr("{NumOfPages}"); SelectButton("Print"); #Should Be set to PRINT for test LogStr("{PrinterName}-••Printing {NumOfPages} pages••"); end; end; ########################################################################## # InitLaserGlobals() #========================================================================= # Author: O. Güracar # Description: initializes the globals for the controls for the # LaserWriter. # Parameters: None #========================================================================= # Example: InitLaserGlobals(); #========================================================================= # History: # OYG 5/6/92 Created ########################################################################## task InitLaserGlobals() begin Global PrinterName:="LaserWriter"; Global CheckBoxOne:={'Font Substitution?','Text Smoothing?','Graphics Smoothing?','Faster Bitmap Printing?'}; Global CheckBoxTwo:={'Flip Horizontal','Flip Vertical','Invert Image','Precision Bitmap Alignment (4% Reduction)','Unlimited Downloadable Fonts in a Document'}; Global ScaleBox:={145,80}; # Replace with value Global POrientationLoc:={80,140}; # Replace with value Global Orientation:={"P","L"}; #Print Dialog Global RadioPrint:={'Black & White','Color/Grayscale'}; end; ########################################################################## # InitImageGlobals() #========================================================================= # Author: Osman Güracar # Description: initializes the globals for the controls for the # Imagewriter. # Parameters: None #========================================================================= # Example: InitImageGlobals(); #========================================================================= # History: # OYG 5/6/92 Created ########################################################################## task InitImageGlobals() begin Global PrinterName:="ImageWriter"; Global CheckBoxOne:={"Tall Adjusted","50% Reduction","No Gaps Between Pages"}; Global CheckBoxTwo:={}; Global POrientationLoc:={30,120}; # Replace with value Global Orientation:={"P","L"}; Global ScaleBox:={}; #Print Dialog Global RadioPrint:={'Best','Faster','Draft'}; end; ################################################################################################## # Add any globals for other printer drivers here as "task Init(DriverName)Globals and then make # a call to it as in PrintDocument. ################################################################################################## ########################################################################## # PrintDocument(PrinterName) #========================================================================= # Author: O. Güracar # Description: This script randomly selects the items on the Page Setup # and Print dialog and then prints a specified number of # pages. Feel free to customize the InitGlogals routines # above to if the added functionality in the specific # application you are testing. # Parameters: PrinterName - This is not the name you gave the printer # but the type (ex "LaserWriter" or "ImageWriter") #========================================================================= # Example: PrintDocument(PrinterName); #========================================================================= # History: # OYG 5/6/92 Created # Future Support for the stylewriter,Personal LWLS. ########################################################################## task PrintDocument(PrinterName) begin Global CheckBoxOne,CheckBoxTwo,POrientationLoc,Orientation,ScaleBox,RadioPrint; Global NumOfPages:=1; if (PrinterName = "ImageWriter") begin InitImageGlobals(); #Initialize globals for imagewriter end; if (PrinterName = "LaserWriter") begin InitLaserGlobals();#Initialize globals for imagewriter end; OrientItem:=random(1,2); ##### Add any call to other drivers here ########## if (match[menuitem t:/Page Setup?/ m:'File']) begin select [menuitem t: /Page Setup?/ m: 'File']; DoCheckBox(CheckBoxOne); DoOrientation(POrientationLoc,Orientation[OrientItem]);#Put "P" or "L" if (match[button t:"Options"]!) begin select[button t:"Options"]; if (CheckBoxTwo) begin DoCheckBox(CheckBoxTwo); select[button t:"OK"]; end; end; if (ScaleBox) begin DoRanScale(scaleBox,25,200); end; if (match[button t:"OK"]!) select[button t:"OK"]; else begin type k:{ReturnKey}; end; end; #End PageSetup IF if match[menuitem t:"Print…" m:'File']! select [menuitem t: "Print…" m: 'File']; if match[menuitem t:"Print..." m:'File']! select [menuitem t: "Print..." m: 'File']; DoRadioButton(RadioPrint); PrintPage(NumOfPages); end; #End PrintDocument